﻿//using System;
//using Framework.MVC;
//using Log.Model;
//using Identity.Model;
//using Billing.Model;
//using Billing.IService.Entry;
//using Identity.IService.Entry;
//using Account.Model;
//using Account.IService.Entry;
//using Recharge.Entry;
//using Framework.MVVM.Model;
//using Log.IService;
//using Log.Service;
//using Common.IService;
//using Common.Service;
//using Identity.IService;
//using Identity.Service;
//using Account.IService;
//using Account.Service;
//using Billing.IService;
//using Billing.Service;


//namespace Recharge.Models
//{
//    [ServiceAttribute(typeof(IRechargeOrderService), typeof(RechargeOrderService), "Instance")]
//    [ServiceAttribute(typeof(IRemoteCodeService), typeof(RemoteCodeService), "Instance")]
//    [ServiceAttribute(typeof(IAccountService), typeof(AccountService), "Instance")]
//    [ServiceAttribute(typeof(IIdentityService), typeof(IdentityService), "Instance")]
//    [ServiceAttribute(typeof(ILogService), typeof(LogService), "Instance")]
//    [ServiceAttribute(typeof(ICodeService), typeof(CodeService), "Instance")]
//    public class TBReChargeAccountModel : AsyncModelBase, IWriteLog, IValidateIdentity, IValidateVerifyCode,IGetAccount, INewRechargeOrder
//    {
//        #region Field

//        private const string m_empty_verifycode = "tbcgea000";
//        private const string m_error_verifycode = "tbcgea001";
//        private const string m_complete_verifycode = "tbcgea002";
//        private const string m_error_verifyvalue = "tbcgea003";
//        private const string m_complete_verifyvalue = "tbcgea004";
//        private const string m_empty_identity = "tbcgea005";
//        private const string m_error_identity = "tbcgea006";
//        private const string m_complete_identity = "tbcgea007";
//        private const string m_error_account_format = "tbcgea008";
//        private const string m_error_account_not_exists = "tbcgea009";
//        private const string m_error_service = "tbcgea010";
//        private const string m_complete_getreceiver = "tbcgea011";
//        private const string m_error_neworder_amount = "tbcgea012";
//        private const string m_error_neworder = "tbcgea013";
//        private const string m_complete_neworder = "tbcgea014";

//        private const string m_resource_verify = "vc00";
//        private const string m_resource_user = "u000";

//        private const string m_entry = "entry";
//        private const string m_error = "error";

//        private const string m_errors_verifycode = "verifycode";
//        private const string m_errors_identity = "identity";
//        private const string m_errors_account = "account";
//        private const string m_errors_order = "order";

//        private const string m_split = ";";

//        #endregion Field

//        #region AsyncModelBase

//        protected override void OnInit(Type type)
//        {
//            OnBeginRequest();
//            this.ValidateVerifyCode(m_resource_verify, m_empty_verifycode, m_error_verifycode, m_complete_verifycode, m_error_verifyvalue, m_complete_verifyvalue);

//        }

//        #endregion AsyncModelBase

//        #region Write Log

//        public void OnWriteLogComplete(string eventCode)
//        {
//            OnEndRequest();
//        }

//        public void OnWriteLogError(string eventCode)
//        {
//            OnEndRequest();
//        }

//        #endregion Write Log

//        #region IValidateVerifyCode

//        public string VerifyCode { get; set; }

//        public string Source { get; set; }

//        public string VerifyValue { get; set; }

//        public void OnValidateVerifyCodeComplete(string key, IdentityEntry entry)
//        {
//            OnBeginRequest();
//            this.Log(key, entry);
//            if (string.Equals(key, m_complete_verifyvalue))
//            {
//                this.ValidateIdentity(m_resource_user, m_empty_identity, m_error_identity, m_complete_identity);
//            }

//        }

//        public void OnValidateVerifyCodeError(string key)
//        {
//            OnComplete(m_error,m_errors_verifycode);
//            this.Log(key, new IdentityEntry { code = VerifyCode, source = Source, resource = m_resource_verify, value = VerifyValue });
//        }

//        #endregion IValidateVerifyCode

//        #region IValidateIdentity

//        public string IdentityCode { get; set; }

//        public void OnValidateIdentityComplete(string key, IdentityEntry entry)
//        {
//            OnBeginRequest();
//            this.Log(key, entry);

//            RechargeOrderOwner = entry.value;
//            this.GetAccount(m_error_account_format,m_error_account_not_exists,m_error_service,m_complete_getreceiver);
//        }

//        public void OnValidateIdentityError(string key)
//        {
//            OnComplete(m_error,m_errors_identity);
//            this.Log(key, new IdentityEntry { code = IdentityCode, source = Source, resource = m_resource_user });
//        }

//        #endregion IValidateIdentity

//        #region IGetAccount

//        public string AccountName { get; set; }

//        public void OnGetAccountComplete(string key, AccountEntry entry)
//        {
//            OnBeginRequest();
//            this.Log(key, entry);

//            RechargeOrderReceiver = entry.code;
//            this.NewRechargeOrder(m_error_neworder_amount,m_error_neworder, m_complete_neworder);
//        }

//        public void OnGetAccountError(string key)
//        {
//            OnComplete(m_error,m_errors_account);
//            this.Log(key, Source + m_split + AccountName);
//        }

//        #endregion IGetAccount

//        #region INewRechargeOrder

//        public int RechargeOrderAmount { get; set; }

//        public string RechargeOrderOwner { get; set; }

//        public string RechargeOrderReceiver { get; set; }

//        public string RechargeOrderType { get; set; }

//        public void OnNewRechargeOrderComplete(string key, RechargeOrderEntry entry)
//        {
//            OnComplete(m_entry,entry);
//            this.Log(key, entry);
            
//        }

//        public void OnNewRechargeOrderError(string key)
//        {
//            OnComplete(m_error,m_errors_order);
//            this.Log(key, new RechargeOrderEntry { owner = RechargeOrderOwner, receiver = RechargeOrderReceiver, amount = RechargeOrderAmount, type = RechargeOrderType });
//        }

//        #endregion INewRechargeOrder

//    }
//}